local CATEGORY_NAME = "Fun"

function ulx.rocket( calling_ply, target_plys )

	for _, v in ipairs( target_plys ) do
		if not v:Alive() then
			ULib.tsay( calling_ply, v:Nick() .. " is dead!", true )
			return
		end
		if v.jail then
			ULib.tsay( calling_ply, v:Nick() .. " is in jail", true )
			return
		end
		if v.ragdoll then
			ULib.tsay( calling_ply, v:Nick() .. " is a ragdoll", true )
			return
		end	

		if v:InVehicle() then
			local vehicle = v:GetParent()
			v:ExitVehicle()
		end
		v:SetMoveType(MOVETYPE_WALK)
		tcolor = team.GetColor( v:Team()  )
		local trail = util.SpriteTrail(v, 0, Color(tcolor.r,tcolor.g,tcolor.b), false, 60, 20, 4, 1/(60+20)*0.5, "trails/smoke.vmt")  				
		v:SetVelocity(Vector(0, 0, 2048))
		timer.Simple(2.5, function()
			local Position = v:GetPos()		
			local Effect = EffectData()
			Effect:SetOrigin(Position)
			Effect:SetStart(Position)
			Effect:SetMagnitude(512)
			Effect:SetScale(128)
			util.Effect("Explosion", Effect)
			timer.Simple(0.1, function()
				v:KillSilent() 
				trail:Remove()
			end)
		end)
	end
end

local rocket = ulx.command( CATEGORY_NAME, "ulx rocket", ulx.rocket, "!rocket" )
rocket:addParam{ type=ULib.cmds.PlayersArg }
rocket:defaultAccess( ULib.ACCESS_ADMIN )
rocket:help( "Rockets <user(s)> into the air" )
rocket:logString( "#1s rocketed #2s into the air." )
ulx.addToMenu( ulx.ID_MCLIENT, "Rocket", "ulx rocket" )